<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>提醒事项</title>
	<!-- <script src="js/vue.js"></script> -->
	<script src="js/vue.js">
		
	</script>
    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f4f4f4;
        }
        .app {
            width: 500px;
           min-height: 300px;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            background-color: #fff;
        }
        .header {
            height: 120px;
            background-color: orange;
            padding: 20px;
            box-sizing: border-box;
        }
        .header h1 {
            margin: 0 0 10px;
            font-size: 24px;
            color: #fff;
            text-align: left;
        }
        .header .input-container {
            display: flex;
            align-items: center;
        }
        .header input[type="text"] {
            flex: 1;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            margin-right: 10px;
        }
        .header button {
            padding: 10px 20px;
            background-color: #fff;
            color: orange;
            border: 1px solid #ccc;
            border-radius: 4px;
            cursor: pointer;
        }
        .header button:hover {
            background-color: #f9f9f9;
        }
        .content {
            background-color: #f4f4f4;
            flex: 1;
            overflow-y: auto;
            padding: 10px;
            border-radius: 0 0 8px 8px;
        }
        .content .item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 0;
            border-bottom: 1px solid #ddd;
        }
        .content .item:last-child {
            border-bottom: none;
        }
        .content .item .details {
            display: flex;
            align-items: center;
        }
        .content .item .details span:first-child {
            margin-right: 10px;
            font-weight: bold;
        }
        .content .item .buttons button {
            margin-left: 5px;
            padding: 5px 10px;
            background-color: olive;
            border: 1px solid #ccc;
            border-radius: 4px;
            cursor: #fff;
        }
		
		 .content .item .buttons button [disabled]{
			 background-color: #ccc;
			  cursor: not-allowed;
		 }
		/* .list-enter-from{
			 transform: translateX(100px);
		 }
		 .list-enter-active,
		 .list-leave-active{
			 transition: all .5s ease;
		 }
        .list-leave-to{
			transform: translateX(-100px);
			opacity: 0;
		}
		.list-move{
			transition: transform 0.5 ease;
		}
		 */
		.list-move {
		    transition: transform 0.5s ease;
		}
		.list-enter-active, .list-leave-active {
		    transition: all 0.5s ease;
		}
		.list-enter-from, .list-leave-to {
		    opacity: 0;
		    transform: translateX(30px);
		}
    </style>
</head>
<body>
    <div class="app">
        <div class="header">
            <h1>提醒事项</h1>
            <div class="input-container">
                <input v-model="title" type="text" placeholder="输入提醒事项">
                <button @click="add">添加</button>
            </div>
        </div>
        <transition-group tag='ul' name='list' class="content">
            <div class="item" v-for="(item,index) in list" :key='index'>
                <div class="details">
                    <span>{{index+1}}.</span>
                    <span>{{item}}</span>
                </div>
               <div class="buttons">
                   <button v-if="index < list.length - 1" @click="move(0,index)">下移</button>
                   <button v-else disabled="disabled">下移</button>
                   <button @click="move(1,index)" v-if="index > 0">上移</button>
                   <button v-else disabled="disabled">上移</button>
                   <button @click="list.splice(index, 1)">删除</button> <!-- 删除逻辑 -->
               </div>
            </div>
       </transition-group>
    </div>
	<script>
	Vue.createApp({
	    data() {
	        return {
	            title: '',
	            list: ["吃饭", "睡觉", "运动"]
	        };
	    },
	    methods: {
	        add() { // 添加事项
	            if (this.title.length <= 0) {
	                alert('请输入事项名称');
	                return;
	            }
	            this.list.push(this.title);
	            this.title = ''; // 清空输入框
	        },
	        move(type,i) { // 上移事项
	            if (type == 1) {
	                this.list.splice(i-1,0,this.list[i])
					 this.list.splice(i+1,1)
	                
	            }
	        },
	        // moveDown(index) { // 下移事项
	        //     if (index < this.list.length - 1) {
	        //         const temp = this.list[index + 1];
	        //         this.list[index + 1] = this.list[index];
	        //         this.list[index] = temp;
	        //     }
	        // }
	    }
	}).mount(".app");
	</script>
</body>
</html>